<%@ page language="java" import="java.sql.*" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@page import="java.sql.*"%>
<%@page import="org.edu.system.DBConnect"%>
<%
	String tc_id = (String)(session.getAttribute("UserName"));
	String sql = "SELECT * FROM teacher WHERE tc_id = '" + tc_id + "'";
	System.out.println(sql);
	
	Connection con = DBConnect.getCon();
	Statement stmt = null;
	ResultSet rs = null;
	stmt = con.createStatement();
	rs = stmt.executeQuery(sql);//执行命令
	if (rs.next())// 如果记录集非空，表明有匹配的用户ID
	{
			//正常进行
	} else {
		// 否则登录失败
		// response.sendRedirect ( "MyJsp.jsp" );
		response.sendRedirect("login_failure.jsp");
	}
%>
<html>
<head>
<link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet">
<title>教师教务管理系统 - 个人信息</title>
</head>
<body style="width:900px; margin:0 auto;">	
		<% String driverName = "com.mysql.jdbc.Driver";
		   String userName = "root";
		   String userPwd = "123456";
		   String dbName = "Sa";
		   String url1="jdbc:mysql://localhost:3306/"+dbName;
		   String url2="?user="+userName+"&password="+userPwd;
		   String url3="&useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC";
		   String url =url1+url2+url3;
		   Connection conn = DBConnect.getCon();
		   request.setCharacterEncoding("utf-8");
		   session.setAttribute("tc_id",tc_id);
		   sql="select * from teacher where tc_id=?";
		   PreparedStatement pstmt = conn.prepareStatement(sql);
		   pstmt.setString(1,tc_id);
		   rs=pstmt.executeQuery();
		   if(rs.next()){
			   String id=rs.getString("tc_id");
			   String tc_name=rs.getString("tc_name");
			   String tc_passwd=rs.getString("tc_passwd");
			   String tc_gender=rs.getString("tc_gender");
			   String tc_college=rs.getString("tc_college");
			   String tc_phone=rs.getString("tc_phone");
			   String tc_identity=rs.getString("tc_identity");
			   String tc_location=rs.getString("tc_location");
			   if(rs!=null){}
			   if(pstmt!=null){}
			   if(conn!=null){}
		   %>
		   <div id="main">
		   <table width="100%"  class="table">
				<tr>
				<td width="50%" height="50%">		
					<form action= "tc_xxxg.jsp" method="post" >
					 <table class="table table-striped table-bordered">
					 <tr><th colspan="2" style="text-align:center">个人信息</th></tr>
					  <tr><td>工号:</td><td><input name="tc_id" readonly value=<%=tc_id%>></td></tr>
					  <tr><td>姓名:</td><td><input name="tc_name" readonly value=<%=tc_name%>></td></tr>
					  <tr><td>性别:</td><td><input name="tc_gender" readonly value=<%=tc_gender%>></td></tr>
					  <tr><td>所属院系:</td><td><input name="tc_college" readonly value=<%=tc_college%>></td></tr>
					  <tr><td>手机号:</td><td><input name="tc_phone" value=<%=tc_phone%>></td></tr>
					  <tr><td>身份证号:</td><td><input name="tc_identity" value=<%=tc_identity%>></td></tr>
					  <tr><td>住址:</td><td><input name="tc_location" value=<%=tc_location%>></td></tr>
					 <tr align="center"><td colspan="2"><input type="submit" class="btn btn-success" value="提交修改"></td></tr>
					 </table>
					 </form>		
					 </td>
					 <td width="50%" height="50%">
					<form action= "tc_mmxg.jsp" method="post" >
					 <table class="table table-striped table-bordered">
						<tr><td colspan="2"><input type=hidden name="tc_id" value=<%=tc_id%>></td></tr>
			          <tr><th colspan="2" style="text-align:center">修改密码</th></tr>
					  <tr><td>新密码:</td><td><input type="password" name="tc_npasswd_1" value="" ></td></tr>
					  <tr><td>确认新密码:</td><td><input type="password" name="tc_npasswd_2" value=""  ></td></tr>
					 <tr align="center">
					  <td colspan="2"><input type="submit" class="btn btn-success" value="提交修改"></td></tr>
					  </table>
					 </form>
					 </td>
					 </tr>
					 </div>
					 <%}
		   else{%>没有找到合适条件的记录！<%
			   if(rs!=null){}
		   if(pstmt!=null){}
		   if(conn!=null){}
		   } %>
		   </body>
</html>